<!--学生个人信息页面-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<%
	String stu_id = (String) (session.getAttribute("UserName"));
	String sql = "SELECT * FROM student WHERE stu_id = '" + stu_id + "'";
	System.out.println(sql);

	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{

		//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="utf-8">
<title>学生后台系统 - 个人信息</title>
</head>
<body style="width:900px; margin:0 auto;">
<body>
	<br><br><br>
	<div class="info"><!-- 利用上面的sessionget获取当前用户-->
		<table class="table table-striped table-bordered" border="1"><!-- 设置表格 -->
			<tr><!-- 设置表头 -->
				<th>学生id</th>
				<th>学生姓名</th>
				<th>学生密码</th>
				<th>学生性别</th>
				<th>学生班级</th>
				<th>课程列表</th>
				<th>手机号码</th>
				<th>身份证号</th>
				<th>居住地址</th>
				<th>学分总和</th>
			</tr>
			<%
				PreparedStatement pst = null;
				ResultSet rs1 = null;
				try {
					String sql_select = "SELECT * FROM student WHERE stu_id = '" + stu_id + "'";
					Connection con1 = DBConnect.getCon();
					request.setCharacterEncoding("utf-8");
					System.out.println(sql_select);
					pst = con1.prepareStatement(sql_select);
					rs1 = pst.executeQuery();
					System.out.println(pst);
					System.out.println(rs1);//匹配并循环输出账户密码
					while (rs1.next()) {
			%>
			<tr><!-- 设置表格跟随着表头显示 -->
				<td><font size="2"><%=rs1.getString("stu_id")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_name")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_passwd")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_gender")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_class")%></font></td>
				<td><font size="2"><%=rs1.getString("course_list")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_phone")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_identity")%></font></td>
				<td><font size="2"><%=rs1.getString("stu_location")%></font></td>
				<td><font size="2"><%=rs1.getString("total_credit")%></font></td>
			</tr>
		
		</table>
	</div>
	<div class="pwchange">
	<table class="table table-striped table-bordered" border="1" align="center">
	<br></br>
		<tr><th style="text-align:center"> 修改个人信息</th></tr>
		<form action="stu_update.jsp" name="pasw" method="post"><!-- 将表单中数据传到adm_update.jsp -->
		<tr><td align="center">姓名：<input type="text" name="name" value=<%=rs1.getString("stu_name")%> class=“item” maxlength='32'> </td></tr>
	    <tr><td align="center">性别：<select name="gender" class="select">
					<option>男</option>
					<option>女</option>
				</select> </td></tr>
	    <tr><td align="center"> 手机号码：<input type="text" name="phone" value=<%=rs1.getString("stu_phone")%> class=“item” maxlength='32'> </td></tr>
	    <tr><td align="center">身份证号：<input type="text" name="identity" value=<%=rs1.getString("stu_identity")%> class=“item” maxlength='32'> </td></tr>
	    <tr><td align="center"> 居住地址：<input type="text" name="location" value=<%=rs1.getString("stu_location")%> class=“item” maxlength='32'> </td></tr>
			<tr><td align="center"><input type="submit" class="btn btn-primary btn-sm" value="提交" ></td></tr>
		</form>
		</table>
	</div>
		<%
				}
				} catch (Exception e) {
					out.println(e);
				}
			%>
</body>

</html>